package com.mck.controller;

import com.mck.entity.Result;
import com.mck.entity.ScoreTotal;
import com.mck.service.ScoreTotalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0.0
 * @Author mck
 * @Date 2025/4/16 上午11:58
 * @注释
 */
@RestController
@RequestMapping("/api/public/score/total")
@Slf4j
public class ScoreTotalController {

    @Autowired
    private ScoreTotalService scoreTotalService;

    /**
     * 获取成绩总分
     */
    @PostMapping
    public Result getScoreTotal(@RequestBody(required = false) ScoreTotal scoreTotal) {
        log.info("获取成绩总分");

        List<ScoreTotal> scoreTotalList = scoreTotalService.getScoreTotalList(scoreTotal);
        return Result.success(scoreTotalList);
    }

    @GetMapping("/compute")
    public Result computeScoreTotal() {
        log.info("计算成绩总分");

        scoreTotalService.computeScoreTotalRank();
        return Result.success();
    }
}
